using System;
using System.Collections.Generic;
namespace Microsoft.Phone.Controls.Maps.Core
{
	internal sealed class TfeZoomLevelRange
	{
		private readonly List<int> generations = new List<int>();
		private readonly byte maxZoomLevel;
		private readonly byte minZoomLevel;
		private readonly List<string> regions = new List<string>();
		public int MinimumZoom
		{
			get
			{
				return (int)this.minZoomLevel;
			}
		}
		public int MaximumZoom
		{
			get
			{
				return (int)this.maxZoomLevel;
			}
		}
		public TfeZoomLevelRange(byte minZoomLevel, byte maxZoomLevel)
		{
			this.minZoomLevel = minZoomLevel;
			this.maxZoomLevel = maxZoomLevel;
		}
		public void AddRegion(string basequadKey, int generation)
		{
			this.regions.Add(basequadKey);
			this.generations.Add(generation);
		}
		public int GetGeneration(string quadKey)
		{
			if (quadKey.get_Length() < (int)this.minZoomLevel || quadKey.get_Length() > (int)this.maxZoomLevel)
			{
				return -1;
			}
			int num = this.regions.BinarySearch(quadKey);
			if (num >= 0)
			{
				return this.generations.get_Item(num);
			}
			num = ~num;
			if (num == 0 || num > this.regions.get_Count())
			{
				return -1;
			}
			if (quadKey.StartsWith(this.regions.get_Item(num - 1), 4))
			{
				return this.generations.get_Item(num - 1);
			}
			return -1;
		}
	}
}
